#delimit ;
*REStat paper, "Breastfeeding and Children's Early Cognitive Outcomes";
log using c:/local_c/bfeed3/stata08.log,replace;
clear;
set mem 40m;
set more off;
set matsize 800;

set seed 12345;


use c:/local_c/bfeed3/mns082;

gen custwtx = int(custwt);

drop custwt;

**missing obs., dvs;
replace regnc = 0 if regdv == 1;
replace regs = 0 if regdv == 1;
replace regw = 0 if regdv == 1;
replace prenat1 = 0 if predv == 1;
replace msmoke = 0 if predv == 1;
replace csect = 0 if predv == 1;
replace gestlt35 = 0 if gestdv == 1;
replace gest3537 = 0 if gestdv == 1;
replace bw55 = 0 if bw55dv == 1;
replace afqt = 0 if afqtdv == 1;

replace ptp = 0 if pftpdv == 1;
replace ftp = 0 if pftpdv == 1;

replace sped = 0 if marbirth == 0;
replace sped = 0 if speddv == 1;

gen hgc2 = hgcyob*hgcyob;

gen hhgc = chisp*hgcyob;

gen b35 = cblack*gestlt35;

gen bafqt = cblack*afqt;

gen sped2 = sped*sped;


psmatch2   bfeed cfemale cblack chisp pwhte bapt79 cath79 hgcyob marbirth ptp ftp pftpdv
           agebirth momfor regnc regs regw regdv prenat1 msmoke csect predv
           border1 border2 bw55 bw55dv gestlt35 gest3537 gestdv sped speddv
           afqt afqtdv b35 hgc2 hhgc bafqt sped2
          , outcome(math56) trim(3) logit kernel k(epan) bw(.05) common;
		  
bs "psmatch2 bfeed cfemale cblack chisp pwhte bapt79 cath79 hgcyob marbirth ptp ftp pftpdv
           agebirth momfor regnc regs regw regdv prenat1 msmoke csect predv
           border1 border2 bw55 bw55dv gestlt35 gest3537 gestdv sped speddv
           afqt afqtdv b35 hgc2 hhgc bafqt sped2, out(math56) 
           logit kernel k(epan) bw(.05) trim(3) common" "r(att)", reps(500);

psmatch2   bfeed cfemale cblack chisp pwhte bapt79 cath79 hgcyob marbirth ptp ftp pftpdv
           agebirth momfor regnc regs regw regdv prenat1 msmoke csect predv
           border1 border2 bw55 bw55dv gestlt35 gest3537 gestdv sped speddv
           afqt afqtdv b35 hgc2 hhgc bafqt sped2
          , outcome(read56) trim(3) logit kernel k(epan) bw(.05) common;
		  
bs "psmatch2 bfeed cfemale cblack chisp pwhte bapt79 cath79 hgcyob marbirth ptp ftp pftpdv
           agebirth momfor regnc regs regw regdv prenat1 msmoke csect predv
           border1 border2 bw55 bw55dv gestlt35 gest3537 gestdv sped speddv
           afqt afqtdv b35 hgc2 hhgc bafqt sped2, out(read56) 
          logit kernel k(epan) bw(.05) trim(3) common" "r(att)", reps(500);

**pstest cfemale cblack chisp pwhte bapt79 cath79 hgcyob marbirth ptp ftp pftpdv
  **         agebirth momfor regnc regs regw regdv prenat1 msmoke csect predv
    **       border1 border2 bw55 bw55dv gestlt35 gest3537 gestdv
      **     afqt afqtdv  hgc2 bhgc hhgc ageb2 bafqt ;

**regression based balancing test from Smith paper;
drop if _support==0;

gen pscore2 = _pscore*_pscore;
gen pscore3 = _pscore*_pscore*_pscore;
gen pscore4 = _pscore*_pscore*_pscore*_pscore;
gen bfp = bfeed*_pscore;
gen bfp2 = bfeed*_pscore*_pscore;
gen bfp3 = bfeed*_pscore*_pscore*_pscore;
gen bfp4 = bfeed*_pscore*_pscore*_pscore*_pscore;


reg cfemale _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg cblack _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg chisp _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg pwhte _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg bapt79 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg cath79 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg hgcyob _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg marbirth _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg agebirth _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg momfor _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg regnc _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg regs _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg regw _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg regdv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg prenat1 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg msmoke _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg csect _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg predv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg border1 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg border2 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg bw55 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg bw55dv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg gestlt35 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg gest3537 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg gestdv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg afqt _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg afqtdv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg ptp _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg ftp _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg pftpdv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg sped _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg speddv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg b35 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg hgc2 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg hhgc _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;     

reg bafqt _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;    
 
reg sped2 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;    
  

clear matrix;

log close;


